package com.qf.test;

import com.qf.daomain.Customer;
import com.qf.daomain.Linkman;
import com.qf.mapper.CustomerMapper;
import com.qf.mapper.LinkmanMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/9/26 15:23
 */

public class Demo5 {
    @Test
    public void Test ()throws Exception{
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = build.openSession();
        CustomerMapper mapper = sqlSession.getMapper(CustomerMapper.class);
        Customer customer = mapper.findCustomerAndLinkmanSetByCustomerId(1);
        System.out.println(customer);
        for (Linkman linkman : customer.getLinkmanSet()) {
            System.out.println(linkman);
        }

    }
}
